﻿using ConfigurationCommon;
using Enyim.Caching.Configuration;
using Microsoft.AspNetCore.Mvc;
using NetCore6WebAPITestOneEntity;

namespace NetCroe6WebAPITestOne.Controllers
{
    [ApiController]
    [Route("ueerlogin")]
    [Produces("application/json")]
    public class ConfigruationExpController : ControllerBase
    {
        ConfigurationScopeHelper _configurationHelper;

        public ConfigruationExpController(ConfigurationScopeHelper configurationHelper)
        {
            _configurationHelper = configurationHelper;
        }

        /// <summary>
        /// 获取默认配置文件数据示例
        /// </summary>
        /// <returns></returns>
        [HttpGet("ConfigurationTest")]
        public object ConfigurationTest()
        {
            return ConfigurationStaticHelper._usermysqlConnectionString;
            //return _configurationHelper._usermysqlConnectionString;
        }

        /// <summary>
        /// 获取配置appsetting1.json数据示例
        /// </summary>
        /// <returns></returns>
        [HttpGet("ConfigurationTest1")]
        public object ConfigurationTest1()
        {
            return _configurationHelper._appSettingsModel;
        }

        /// <summary>
        /// 获取配置appsetting2.json数据示例
        /// </summary>
        /// <returns></returns>
        [HttpGet("ConfigurationTest2")]
        public object ConfigurationTest2()
        {
            AppSettingsModel modelMysql = _configurationHelper._optionsSnapshot.Get("mysql");
            AppSettingsModel modelMongodb = _configurationHelper._optionsSnapshot.Get("mongodb");
            return new
            {
                modelMysql = modelMysql,
                modelMongodb = modelMongodb,
                appSettingsModel = _configurationHelper._appSettingsModel
            };
        }
    }
}
